<?php 
foreach($data as $i => $register)  
{ 
    if ($i == 0)  
    { 
        $header = array(); 
        foreach($register['Register'] as $field => $value)  
        { 
            $header[] = $labels[$field]; 
        } 
        $excel->addRow($header); 
    } 
    $excel->addRow($register['Register']); 
} 

$file = 'register-'.date('d-m-Y'); 
$excel->render($file); 
